package com.zl.learning.collection;

import java.util.HashMap;

public class MapBuilder {

    public static <K, V> HashMapBuild<K, V> newHashMap(K k, V v) {
        return new HashMapBuild<>(k, v);
    }

    static class HashMapBuild<K, V> {
        private HashMap<K, V> map;

        HashMapBuild(K k, V v) {
            HashMap<K, V> map = new HashMap<>();
            map.put(k, v);
            this.map = map;
        }

        public HashMapBuild<K, V> build(K k, V v) {
            this.map.put(k, v);
            return this;
        }

        public HashMap<K, V> builder() {
            return this.map;
        }
    }
}
